<?php 

namespace app\admin\controller;

use think\Controller;
use think\Request;
use think\Session;

class AdminController extends Controller
{
	public function _initialize()
	{
		//判断session是否存在
		if(empty(Session::get('admin_user'))){
			//跳转到 登陆页
			$this->redirect("/");
		} else{
			$m = Session::get('admin_user');
			$a = Session::get('nodelist');
			// var_dump($m);
			// var_dump($a);
			$request = Request::instance();
			$mname = $request->controller();
			$aname = $request->action();
			if($m['username'] !== 'admin') {
				if(empty($a[$mname]) || !(in_array($aname,$a[$mname]))) {
					$this->error('你没有该操作的权限!');
					exit;
				}
			}
		}

		
	}


}
